#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(int x ,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }
    

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }
private:
    int _ix;
    int _iy;
};

//拷贝构造的第二种调用时机
//当函数的实参和形参都是对象时
//用实参初始化形参也会调用拷贝
void func1(Point pt)//值传递会发生复制
{
    pt.print();
}

void test0(){
    Point p1(1,8);
    func1(p1);
}

//拷贝构造的第三种调用时机
Point func2(){
    Point p2(8,9);
    return p2;//执行return语句时会发生复制
}

void test1(){
    func2();
}



int main(void){
    test1();
    return 0;
}
